package com.ruoyi.shenji.utils;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.ruoyi.common.core.domain.TreeSelect;
import com.ruoyi.shenji.domain.TableData;
import com.ruoyi.shenji.domain.Vo.TableDataVo;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
@Data
public class TableTreeSelect implements Serializable {

    /** 节点ID */
    private Integer id;

    /** 节点名称 */
    private String label;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TableTreeSelect> children;

    public TableTreeSelect()
    {

    }

    public TableTreeSelect(TableDataVo table)
    {
        this.id = table.getId();
        this.label = table.getName();
        this.children = table.getChildren().stream().map(TableTreeSelect::new).collect(Collectors.toList());
    }

    public void setChildren(List<TableTreeSelect> children)
    {
        this.children = children;
    }
    public List<TableTreeSelect> getChildren()
    {
        return children;
    }
}
